package il.ac.braude.sona.gui.forms.myforms;

import il.ac.braude.sona.constants.ButtonPermission;
import il.ac.braude.sona.constants.Resources;
import il.ac.braude.sona.constants.Statuses;
import il.ac.braude.sona.gui.forms.FormFrame;
import il.ac.braude.sona.gui.forms.FormPanel;
import il.ac.braude.sona.gui.forms.questions.QButton;
import il.ac.braude.sona.gui.forms.questions.QComboBox;
import il.ac.braude.sona.gui.forms.questions.QTextField;

import java.awt.Color;
import java.awt.event.ActionListener;
/**
 * The ApproveTimeLineForm is a FormFrame that create the gui for the approve time line stage
 *  
 * @author Ofek Ron
 * @author Avihay Avitan
 * @author Nitzan Inbar
 * @author Sasha Rozenthal
 */
public class ApproveTimeLineForm extends  FormFrame {
	/**
	 * reqid - the involved request of the stage
	 */
	private String reqid;
	/**
	 * stage - the stage that the form is presented for (surveying or execution)
	 */
	private String stage;
	/**
	 * q - question for viewing the time line worker entered
	 */
	public QTextField q;
	/**
	 * form - the presented formPanel
	 */
	public FormPanel form;
	/**
	 * editDaysButton - QButton that opens the editing option for estimating time line
	 */
	public QButton editDaysButton;
	/**
	 * EstimateTime - QComboBox question for selecting the new time line
	 */
	public QComboBox EstimateTime= new QComboBox("Choose evaluated days:",1,99);

	/**
	 * Constructs the ApproveTimeLineForm.
	 * initiate the GUI for User
	 * 
	 * @param reqid -the involved request of the stage
	 * @param stage - the stage that the form is presented for (surveying or execution)
	 * @param time - the time that worker asking for approval
	 * @param control - the controller that listen to editDaysButton
	 */
	public ApproveTimeLineForm(String reqid, String stage,String time,ActionListener control) {
		super(ButtonPermission.ApproveTimeLine, Resources.Strings.Approve);
		form = new FormPanel();
		setReqid(reqid);
		setStage(stage);
		if (stage.equals(Statuses.Approve_Surveying_Time))
		form.addTitleWithUnderline("Approve time for stage 'Surveying' at request: "+reqid);
		if (stage.equals(Statuses.Approve_Execution_Time))
		form.addTitleWithUnderline("Approve time for stage 'Execution' at request: "+reqid);
		q=new QTextField("Worker evaluation days:");
		q.setDefaultAnswer(time);
		q.setEditable(false);
		q.setBackgroudColor(Color.LIGHT_GRAY);
		EstimateTime.setDefaultAnswer(Integer.parseInt(time)-1	);
		EstimateTime.setVisible(false);
		form.addQuestion(EstimateTime);
		form.addQuestion(q);
		form.addQuestion(editDaysButton=new QButton(Resources.Strings.EditDays,control));
		setFormPanel(form);
	}
	
	/**
	 * returns the field reqid
	 * @return reqid
	 */
	public String getReqid() {
		return reqid;
	}
	/**
	 * sets the field reqid
	 * @param reqid
	 */
	public void setReqid(String reqid) {
		this.reqid = reqid;
	}
	/**
	 * returns the field stage
	 * @return stage
	 */
	public String getStage() {
		return stage;
	}
	/**
	 * sets the field stage
	 * @param stage
	 */
	public void setStage(String stage) {
		this.stage = stage;
	}
	
	

}
